﻿@model SearchListVM
@{
    ViewBag.Title = "搜索";
    ViewBag.Search = Model.SearchTerm;
}



<div class="container page page-search">
    <div class="content">
        <div class="searchform">
            @using (Html.BeginForm("Index", "Search", FormMethod.Get, new { @class = "form-inline" }))
            {
                
                    @Html.TextBoxFor(m => m.SearchTerm, new { @class = "form-control", autocomplete = "off", placeholder = "关键字" })
               
                <button type="submit" class="btn btn-primary"><i class="fa fa-search fa-fw"></i>搜索</button>
            }
        </div>
        <section>
@if (Model.SearchIndexData.Any())
{
            foreach (var item in Model.SearchIndexData)
            {
                <a href="@item.Url" class="item">
                    @if (!string.IsNullOrEmpty(item.ImageUrl))
                    {
                        <div class="thumb pull-left">
                            <img src="@item.ImageUrl" alt="@item.Name" />
                        </div>
                    }
                  
                    <div class="des">
                        <h3 class="title">
                            @Html.Raw(System.Text.RegularExpressions.Regex.Replace(item.Name, Model.SearchTerm, "<strong>" + Model.SearchTerm + "</strong>", System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                        </h3>
                        <p class="url">@item.Url</p>
                        <p>
                            @Html.Raw(System.Text.RegularExpressions.Regex.Replace(item.Description, Model.SearchTerm, "<strong>" + Model.SearchTerm + "</strong>", System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                        </p>
                    </div>                  
                </a>
            }	
            }
            else
            {
            <div class="alert alert-info">
                <i class="iconfont icon-info"></i> 没有找到任何记录！
            </div>
            }
        </section>
        <footer class="list-footer">
            <div class="row">
                <div class="col-sm-7">
                    @Html.PagedListPager(Model.SearchIndexData, page => Url.Action("Index", new { page = page }))
                </div>
                <div class="col-sm-5">
                    <div class="count text-right">
                      
                          <strong>@Model.TotalCount</strong>条记录
                           
                  
                    </div>
                </div>
            </div>
        </footer>
    </div>
</div>